package com.shopping.admin.config;

import com.shopping.admin.Intercepter.LogInterceptercepter;
import com.shopping.admin.Intercepter.UserAuthorizationIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: shopping-mall
 * @ClassName WebConfig
 * @description:
 * @author: zlw
 * @create: 2024-04-16 23:10
 * @Version 1.0
 **/
//拦截器配置
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private UserAuthorizationIntercepter userAuthorizationIntercepter;
    @Autowired
    private LogInterceptercepter logInterceptercepter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录权限拦截admin下的所有请求
        registry.addInterceptor(userAuthorizationIntercepter).addPathPatterns("/admin/**");
        //日志记录拦截admin下的所有请求
        registry.addInterceptor(logInterceptercepter).addPathPatterns("/admin/**");
    }
}
